The present disclosure generally relates to formation of optical elements with refractive indices that vary spatially in at least one dimension. More specifically, the present disclosure relates to a method and system for producing an optical waveguide, also known as a light guide, that has a smoothly varying refractive index. Optical waveguides have many uses. One type of optical waveguide is a graded index lens, which is commonly used for transferring an image or a beam of light from one location to another. Graded index lenses generally have an index that is highest in the center of the lens, and then gradually decreases radially outwards. Thus, the change in index occurs along two dimensions. For example, if the lens lies along the x-y plane of an x-y-z coordinate system, the index might vary in both the x and y directions. Besides graded index lenses, optical waveguides that vary in only one dimension also have many practical applications. However, conventional methods for manufacturing graded index lenses tend to be complicated and are not particularly suited for producing an index profile that varies in only one dimension. Additionally, these conventional methods tend to produce lenses that are poor at guiding light along the thickness direction. For example, graded index lenses produced by co-extrusion of polymer layers have much less scatter for light propagating at near-perpendicular angles to the plane of the layers, but very high scatter for light propagating along the layers. Accordingly, there is a need for techniques for reliably producing optical waveguides with refractive index profiles that vary in one dimension.